# 统一配置管理

import os
from typing import List
from pydantic_settings import BaseSettings

class BaseConfig(BaseSettings):
    """基础配置类"""
    # 项目信息
    VERSION: str = "1.0.0"
    API_PREFIX: str = "/api/v1"
    
    # 安全配置
    API_KEY_HEADER: str = "X-API-Key"
    API_KEY: str = os.getenv("API_KEY", "123456a")
    
    # CORS配置
    CORS_ORIGINS: List[str] = ["http://localhost:3000"]
    
    # 文件配置
    MAX_AUDIO_SIZE_MB: int = 50
    MAX_VIDEO_SIZE_MB: int = 100
    
    # 语言配置
    DEFAULT_AUDIO_LANGUAGE: str = "zh-CN"
    DEFAULT_VIDEO_LANGUAGE: str = "zh"
    
    model_config = {
        "case_sensitive": True,
        "env_file": ".env"
    }

class ServiceConfig(BaseConfig):
    """服务配置基类"""
    TEMP_UPLOAD_DIR: str = "uploads"
    OUTPUT_DIR: str = "output"
    
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        os.makedirs(self.TEMP_UPLOAD_DIR, exist_ok=True)
        os.makedirs(self.OUTPUT_DIR, exist_ok=True)

# 全局配置实例
settings = BaseConfig()